<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/context/mytags.jsp"%>
<!DOCTYPE html>
<html>
 <head>
  <title>SHOPS</title>
  <t:base type="jquery,easyui,tools,DatePicker"></t:base>
  <t:base type="uploadify"></t:base>
  <script type="text/javascript">
  //编写自定义JS代码
  </script>
 </head>
 <body>
		<t:formvalid formid="formobj" dialog="true" usePlugin="password" layout="table" action="${action}" tiptype="6" >
					<input id="id" name="id" type="hidden" value="${shopsPage.id }"/>
		<table style="width: 99%;" cellpadding="0" cellspacing="1" class="formtable">
					<tr>
						<td align="right">
							<label class="Validform_label">
								所属会员:
							</label>
						</td>
						<td class="value">
						    <input id="fullname" name="fullname" type="text" maxlength="150" style="width: 170px"  datatype="*"  ignore="checked"  value='${shopsPage.fullname}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">所属会员</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								企业编号:
							</label>
						</td>
						<td class="value">
						    <input id="shopid" name="shopid" type="text" maxlength="19" style="width: 150px"  datatype="n"  ignore="checked"  value='${shopsPage.shopid}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">商铺编号</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								企业名称:
							</label>
						</td>
						<td class="value">
						    <input id="shopname" name="shopname" type="text" maxlength="150" style="width: 150px"  datatype="*"  ignore="checked"  value='${shopsPage.shopname}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">商铺名称</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								主营产品:
							</label>
						</td>
						<td class="value">
						    <input id="products" name="products" type="text" maxlength="500" style="width: 150px"  ignore="ignore"  value='${shopsPage.products}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">主营产品</label>
						</td>
						<%-- <td align="right">
							<label class="Validform_label">
								企业类型:
							</label>
						</td>
						<td class="value">
									<t:dictSelect field="shoptype" type="list"  datatype="*"  typeGroupCode="SHOPTYPE"   defaultVal="${shopsPage.shoptype}" hasLabel="false"  title="商铺类型" ></t:dictSelect>     
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">商铺类型</label>
						</td> --%>
						<td align="right">
							<label class="Validform_label">
								二维码地址:
							</label>
						</td>
						<td class="value">
						    <input id="qrcode" name="qrcode" type="text" maxlength="150" style="width: 150px"    ignore="checked"  value='${shopsPage.qrcode}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">二维码地址</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								企业状态:
							</label>
						</td>
						<td class="value">
									<t:dictSelect field="shopstate" type="list"  datatype="*"  typeGroupCode="SHOPSTATE"   defaultVal="${shopsPage.shopstate}" hasLabel="false"  title="商铺状态" ></t:dictSelect>     
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">商铺状态</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								企业概况状态:
							</label>
						</td>
						<td class="value">
						    <t:dictSelect field="zzpd" type="list"  datatype=""  typeGroupCode="SHOPSTATE"   defaultVal="${shopsPage.zzpd}" hasLabel="false"  title="商铺状态" ></t:dictSelect>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">企业概况状态</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								地址:
							</label>
						</td>
						<td class="value">
						    <input id="address" name="address" type="text" maxlength="150" style="width: 150px"   ignore="checked"  value='${shopsPage.address}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">地址</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								传真:
							</label>
						</td>
						<td class="value">
						    <input id="faxnum" name="faxnum" type="text" maxlength="150" style="width: 150px"   ignore="checked"  value='${shopsPage.faxnum}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">传真</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								电话:
							</label>
						</td>
						<td class="value">
						    <input id="mobile" name="mobile" type="text" maxlength="150" style="width: 150px"    ignore="checked"  value='${shopsPage.mobile}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">电话</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								邮箱:
							</label>
						</td>
						<td class="value">
						    <input id="email" name="email" type="text" maxlength="150" style="width: 150px"    ignore="checked"  value='${shopsPage.email}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">邮箱</label>
						</td>
						<td align="right">
							<label class="Validform_label">
								网址:
							</label>
						</td>
						<td class="value">
						    <input id="websiteurl" name="websiteurl" type="text" maxlength="150" style="width: 150px"    ignore="checked"  value='${shopsPage.websiteurl}'/>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">网址</label>
						</td>
					</tr>
					<tr class="forVerify" style="display:none;">
						<td align="right">
							<label class="Validform_label">
								企业logo:
							</label>
						</td>
						<td class="value" colspan="5">
			<t:webUploaderOnline name="field001" url="filedeal" displayTxt="false" auto="true" buttonText="选择图片" buttonStyle="btn-blue btn-S" type="image" fileNumLimit="1" pathValues="${shopsPage.shoplogo}"></t:webUploaderOnline>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">商铺logo</label>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								轮播图:
							</label>
						</td>
						<td class="value" colspan="5">
							<t:webUploaderOnline name="field1" url="filedeal" displayTxt="false" auto="true" buttonText="选择图片" buttonStyle="btn-blue btn-S" type="image" fileNumLimit="1" pathValues="${lbimg}"></t:webUploaderOnline>
						    <table id="qrcode_fileTable"></table>
						</td>
					</tr>
					<tr>
						<td align="right">
							<label class="Validform_label">
								企业概况:
							</label>
						</td>
						<td class="value"  colspan="5" >
						<script type="text/javascript"  charset="utf-8" src="plug-in/ueditor/ueditor.config.js"></script>
									<script type="text/javascript"  charset="utf-8" src="plug-in/ueditor/ueditor.all.min.js"></script>
                                <textarea name="survey" id="survey" style="width: 650px;height:300px">${shopsPage.survey }</textarea>

                                <script type="text/javascript">
							        var survey_editor = UE.getEditor('survey');
								    </script>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">企业概况</label>
						</td>
					</tr>
					
					<tr>
						<td align="right">
							<label class="Validform_label">
								产品介绍:
							</label>
						</td>
						<td class="value"  colspan="5" >
                                <textarea name="productdes" id="productdes" style="width: 650px;height:300px">${shopsPage.productdes }</textarea>
                                <script type="text/javascript">
							        var productdes_editor = UE.getEditor('productdes');
								</script>
							<span class="Validform_checktip"></span>
							<label class="Validform_label" style="display: none;">产品介绍</label>
						</td>
					</tr>
					<table id="tabVerify" style="margin-top:10px;width: 99%;display:none;" cellpadding="0" cellspacing="1" class="formtable">
						<input id="verifyflag" name="verifyflag" type="hidden" value="false"/>
						<tr >
							<td align="right">
								<label class="Validform_label">
									审核意见:
								</label>
							</td>
							<td class="value">
							  	<textarea id="verifynote" name="verifynote" style="height:auto;width:850px;" rows="6" ignore="ignore" ></textarea>
							</td>
						</tr>
					</table>
			</table>
		</t:formvalid>
 </body>
 <script type="text/javascript">
		  	//加载 已存在的 文件
		  	$(function(){
	  			var cgFormId=$("input[name='id']").val();
		  		$.ajax({
		  		   type: "post",
		  		   url: "shopsController.do?getFiles&id=" +  cgFormId,
		  		   success: function(data){
		  			 var arrayFileObj = jQuery.parseJSON(data).obj;
		  			 
		  			$.each(arrayFileObj,function(n,file){
		  				var fieldName = file.field.toLowerCase();
		  				var table = $("#"+fieldName+"_fileTable");
		  				var tr = $("<tr style=\"height:34px;\"></tr>");
		  				var title = file.title;
		  				if(title.length > 15){
		  					title = title.substring(0,12) + "...";
		  				}
		  				var td_title = $("<td>" + title + "</td>");
		  		  		var td_download = $("<td><a style=\"margin-left:10px;\" href=\"commonController.do?viewFile&fileid=" + file.fileKey + "&subclassname=org.jeecgframework.web.cgform.entity.upload.CgUploadEntity\" title=\"下载\">下载</a></td>")
		  		  		var td_view = $("<td><a style=\"margin-left:10px;\" href=\"javascript:void(0);\" onclick=\"openwindow('预览','commonController.do?openViewFile&fileid=" + file.fileKey + "&subclassname=org.jeecgframework.web.cgform.entity.upload.CgUploadEntity','fList',700,500)\">预览</a></td>");
		  		  		tr.appendTo(table);
		  		  		td_title.appendTo(tr);
		  		  		td_download.appendTo(tr);
		  		  		td_view.appendTo(tr);
		  		  		if(location.href.indexOf("load=detail")==-1){
			  		  		var td_del = $("<td><a style=\"margin-left:10px;\" href=\"javascript:void(0)\" class=\"jeecgDetail\" onclick=\"del('cgUploadController.do?delFile&id=" + file.fileKey + "',this)\">删除</a></td>");
			  		  		td_del.appendTo(tr);
		  		  		}
		  			 });
		  		   }
		  		});
		  	});
		  	
		  	/**
		 	 * 删除图片数据资源
		 	 */
		  	function del(url,obj){
		  		var content = "请问是否要删除该资源";
		  		var navigatorName = "Microsoft Internet Explorer"; 
		  		if( navigator.appName == navigatorName ){ 
		  			$.dialog.confirm(content, function(){
		  				submit(url,obj);
		  			}, function(){
		  			});
		  		}else{
		  			layer.open({
						title:"提示",
						content:content,
						icon:7,
						yes:function(index){
							submit(url,obj);
						},
						btn:['确定','取消'],
						btn2:function(index){
							layer.close(index);
						}
					});
		  		}
		  	}
		  	
		  	function submit(url,obj){
		  		$.ajax({
		  			async : false,
		  			cache : false,
		  			type : 'POST',
		  			url : url,// 请求的action路径
		  			error : function() {// 请求失败处理函数
		  			},
		  			success : function(data) {
		  				var d = $.parseJSON(data);
		  				if (d.success) {
		  					var msg = d.msg;
		  					tip(msg);
		  					obj.parentNode.parentNode.parentNode.deleteRow(obj.parentNode.parentNode);
		  				} else {
		  					tip(d.msg);
		  				}
		  			}
		  		});
		  	}
		  	
	  		function jeecgFormFileCallBack(data){
	  			if (data.success == true) {
					uploadFile(data);
				} else {
					if (data.responseText == '' || data.responseText == undefined) {
						$.messager.alert('错误', data.msg);
						$.Hidemsg();
					} else {
						try {
							var emsg = data.responseText.substring(data.responseText.indexOf('错误描述'), data.responseText.indexOf('错误信息'));
							$.messager.alert('错误', emsg);
							$.Hidemsg();
						} catch(ex) {
							$.messager.alert('错误', data.responseText + '');
						}
					}
					return false;
				}
				if (!neibuClickFlag) {
					var win = frameElement.api.opener;
					win.reloadTable();
				}
	  		}
	  		function upload() {
					$('#qrcode').uploadify('upload', '*');	
			}
			
			var neibuClickFlag = false;
			function neibuClick() {
				neibuClickFlag = true; 
				$('#btn_sub').trigger('click');
			}
			function cancel() {
					$('#qrcode').uploadify('cancel', '*');	
			}
			function uploadFile(data){
				if(!$("input[name='id']").val()){
					if(data.obj!=null && data.obj!='undefined'){
						$("input[name='id']").val(data.obj.id);
					}
				}
				if($(".uploadify-queue-item").length>0){
					upload();
				}else{
					if (neibuClickFlag){
						alert(data.msg);
						neibuClickFlag = false;
					}else {
						var win = frameElement.api.opener;
						win.reloadTable();
						win.tip(data.msg);
						frameElement.api.close();
					}
				}
			}
	  	</script>
